<template>
<h1>循环指令</h1>
  <ul>
    <li v-for="uname in arr">{{uname}}}</li>
  </ul>
  <ol>
    <li v-for="item in 9">{{item}}</li>
  </ol>
<table border="1px">
  <caption>商品列表</caption>
  <tr >
    <th>序号</th>
    <th>商品名称</th>
    <th>商品价格</th>
    <th>商品库存</th>
    <th>操作</th>
  </tr>
  <tr v-for="(p,index) in productArr">
    <td>{{index+1}}</td>
    <td>{{p.title}}</td>
    <td>{{p.price}}</td>
    <td>{{p.num}}</td>
    <td><button @click="del(index)">删除</button></td>
  </tr>

</table>

</template>

<script setup>

import {ref} from "vue";

const arr = ref(["张三","李四","王五","赵六"])

const productArr = ref([
    {title:'米猴',price:'1999',num:'5'},
    {title:'爱国华',price:'9999',num:'1300000000'},
    {title:'杂牌',price:'4999',num:'3456789'},
]);

const del = (index)=>{
  if(confirm('您确定要删除此条数据吗?')){
    productArr.value.splice(index,1);
  }

}
</script>

<style scoped>

</style>